<template>
  <div class="cart">
    <van-nav-bar title="购物车"  right-text="编辑" @click-right="edit" />
    <router-view :status="status"></router-view>
  </div>
</template>

<script>
import * as api from "../api/User";
export default {
  name: "cart",
  data(){
    return {
      status:false, //0表示展示状态，1表示编辑状态
    }
  },
  methods: {
    edit(){
      this.status = !this.status;
      if(this.status){
        document.getElementsByClassName("van-nav-bar__text")[0].innerHTML = "完成";
      }else{
        document.getElementsByClassName("van-nav-bar__text")[0].innerHTML = "编辑";
      }
    }
  },
  mounted(){
    api.getCart().then((data)=>{
      if(data.data.result==undefined)
      {
        document.getElementsByClassName("van-nav-bar__text")[0].style.display = 'none';
        this.$router.push("/guesslike");
       }else{
        this.$router.push("/cartlist");
      }
    })
    
  }
};
</script>

<style scoped>
.van-ellipsis {
  font-weight: bold;
  font-size: 30px;
}
.van-icon,.van-nav-bar__text{
  color: #333;
}
</style>